<template>
	<view class="box">
		<u-swiper :effect3d="true" :list="list.image" height="400"></u-swiper>
		<!-- <image :src="list.image"></image> -->
		<view class="title">
			{{list.title}}
		</view>
		<view class="desc">
			{{list.desc}}
		</view>
		<view class="price">
			￥{{list.price}}
		</view>
		<view class="navigation">
			<view class="left">
<!-- 				<view class="item">
					<u-icon name="server-fill" :size="40" :color="$u.color['contentColor']"></u-icon>
					<view class="text u-line-1">客服</view>
				</view>
				<view class="item">
					<u-icon name="home" :size="40" :color="$u.color['contentColor']"></u-icon>
					<view class="text u-line-1">店铺</view>
				</view> -->
				<view class="item car">
					<u-icon name="shopping-cart" :size="40" :color="$u.color['contentColor']"></u-icon>
					<view class="text u-line-1" @click="gogwc()">购物车</view>
				</view>
			</view>
			<view class="right">
				<view class="cart btn u-line-1" @click="gwc()">加入购物车</view>
				<view class="buy btn u-line-1" @click="gof()">立即购买</view>
			</view>
		</view>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				list: []
			}
		},
		methods: {
			gogwc(){
				uni.switchTab({
					url:"../order/index"
				});
			},
			gof() {
				uni.navigateTo({
					url: `../keyboardPay/index?price=${this.list.price}&id=${this.list.id}&quantity=1`
				});
			},
			async gwc() {
				let {
					data: res
				} = await this.$http(`/shoppingCart`, "post", this.vuex_token, {
					user_id: this.vuex_userid,
					shop_id: this.list.id,
					quantity: 1 //默认传1  在购物车中显示商品的数量
				})
				console.log(res)
				if(res){
					uni.showToast({
					    title: res.data.msg,
					    duration: 2000
					});
				}
			}
		},
		onLoad(e) {
			e.image = e.image.split(',')
			this.list = e
		},
	};
</script>

<style lang="scss" scoped>
	.box {
		image {
			width: 100%;
		}

		.title {
			font-size: 40rpx;
			font-weight: 500;
			margin-top: 50rpx;
			margin-left: 60rpx;
		}

		.desc {
			margin-top: 20rpx;
			margin-left: 60rpx;
			color: #a29ca3;
			font-weight: 300;
		}

		.price {
			font-size: 50rpx;
			margin-top: 20rpx;
			margin-left: 60rpx;
			color: #f10215;
			font-weight: 700;
		}
	}

	.navigation {
		width: 100%;
		display: flex;
		justify-content: space-between;
		margin-top: 100rpx;
		border: solid 2rpx #f2f2f2;
		background-color: #ffffff;
		padding: 16rpx 0;
		position: fixed;
		bottom: 1rpx;

		.left {
			display: flex;
			font-size: 20rpx;

			.item {
				margin: 0 30rpx;

				&.car {
					text-align: center;
					position: relative;

					.car-num {
						position: absolute;
						top: -10rpx;
						right: -10rpx;
					}
				}
			}
		}

		.right {
			display: flex;
			font-size: 28rpx;
			align-items: center;

			.btn {
				line-height: 66rpx;
				padding: 0 30rpx;
				border-radius: 36rpx;
				color: #ffffff;
			}

			.cart {
				background-color: #ed3f14;
				margin-right: 30rpx;
			}

			.buy {
				background-color: #ff7900;
			}
		}
	}
</style>
